<?php
/**
 * 标签添加验证类
 * User: 16
 * Date: 2018/1/25
 */
namespace app\api\validate;

use think\Validate;
use data\model\Article as ArticleModel;

class Label extends Validate
{
    protected $rule =   [
        'name'  => 'require|max:25',
        'type'   => 'require|islegal',
    ];

    protected $message  =   [
        'name.require' => '标签名不能为空',
        'type.require'     => '分类不能为空',
        'type.islegal'   => '分类不存在',
    ];

    protected function islegal($value){
        $types = ArticleModel::getArticleType();
        return array_key_exists($value,$types) ? true: false;
    }



}